using NUnit.Framework;

namespace ValidationFramework.Tests
{
  [TestFixture]
  public class ComparePropertyRuleAttributeTest
  {

    
    [Test]
    public void CheckValues()
    {
      var ruleAttribute = new ComparePropertyRuleAttribute("PropertyToCompare", CompareOperator.Equal);
      Assert.AreEqual("PropertyToCompare", ruleAttribute.PropertyToCompare);
      Assert.AreEqual(CompareOperator.Equal, ruleAttribute.Operator);

      var propertyRule = (ComparePropertyRule)ruleAttribute.CreateInstance(new MockPropertyDescriptor<byte>("foo"));
      var parameterRule = (ComparePropertyRule)ruleAttribute.CreateInstance(new MockParameterDescriptor<byte>("foo"));
      var fieldRule = (ComparePropertyRule)ruleAttribute.CreateInstance(new MockFieldDescriptor<byte>("foo"));

      Assert.AreEqual("PropertyToCompare", propertyRule.PropertyToCompare);
      Assert.AreEqual(CompareOperator.Equal, propertyRule.CompareOperator);

      Assert.AreEqual("PropertyToCompare", parameterRule.PropertyToCompare);
      Assert.AreEqual(CompareOperator.Equal, parameterRule.CompareOperator);

      Assert.AreEqual("PropertyToCompare", fieldRule.PropertyToCompare);
      Assert.AreEqual(CompareOperator.Equal, fieldRule.CompareOperator);
    }

      [Test]
      public void CallAttributeTester()
      {
		  AttributeTester.CheckDefaultValues<string>(new ComparePropertyRuleAttribute("PropertyToCompare", CompareOperator.Equal), false, true, true);
		  AttributeTester.CheckNonDefaultValues<string>(new ComparePropertyRuleAttribute("PropertyToCompare", CompareOperator.Equal), false, true, true);
      }

  }
}